package ym.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import ym.mapper.MealRecordMapper;
import ym.pojo.MealRecord;

import java.util.List;

@DubboService
public class MealRecordServiceImpl implements MealRecordService {
    @Autowired
    private MealRecordMapper mealRecordMapper;

    @Override
    public void add(MealRecord mealRecord) {
        mealRecordMapper.insert(mealRecord);
    }

    @Override
    public void update(MealRecord mealRecord) {
        mealRecordMapper.updateById(mealRecord);
    }

    @Override
    public void delete(Integer id) {
        mealRecordMapper.deleteById(id);
    }

    @Override
    public MealRecord findById(Integer id) {
        return mealRecordMapper.selectById(id);
    }

    @Override
    public List<MealRecord> findAll() {
        return mealRecordMapper.selectList(null);
    }

    @Override
    public Page<MealRecord> search(String search, int page, int size) {
        QueryWrapper<MealRecord> queryWrapper = new QueryWrapper<>();
        if (search != null) {

        }
        return mealRecordMapper.selectPage(new Page(page, size), queryWrapper);
    }
}
